var Poker = require('../Poker/Poker.js');

module.exports = {
    _getCardPower: function (value) {
        var point = Poker.getPoint(value);
        if (point > 10) {
            point = 10;
        }
        return point;
    },
    /**
         * @param arrCards
         * @returns {boolean}
         * @private
         */
    isDragon: function (arrCards) {
        //this.arr_sort(arrCards);
        var temp = arrCards.slice();
        temp.sort();
        if (Poker.getPoint(temp[0]) == 1 &&
            Poker.getPoint(temp[1]) == 2 &&
            Poker.getPoint(temp[2]) == 3 &&
            Poker.getPoint(temp[3] == 4) &&
            Poker.getPoint(temp[4]) == 5) {
            return true;
        } else
            return false;
    },
    /**
     * @param objCards
     * @returns {boolean}
     * @private
     */
    isBomb: function (objCards) {
        var ret = false;
        ExObject.eachKeyNum(objCards, function (card, num) {
            if (num == 4)
                ret = true;
        });
        return ret;
    },
    /**
     * @param arrCards
     * @returns {boolean}
     * @private
     */
    isFiveCalf: function (arrCards) {
        var sum = 0;
        for (var i = 0; i < 5; i++) {
            var card = this._getCardPower(arrCards[i]);
            if (card > 5){
                return false;
            }
            sum += card;
        }
        if (sum <= 10)
            return true;
        else return false;
    },
    /**
     * @param arrCards
     * @returns {boolean}
     * @private
     */
    isWHN: function (arrCards) {
        var ret = true;
        for (var i = 0; i < 5; i++) {
            if (this._getCardPower(arrCards[i]) <= 10) {
                ret = false;
            }
        }
        return ret;
    }
}